﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SharpSphinx.Linguist.Acoustic
{
    public class HMMPool
    {

        private IAcousticModel Model;
        private Unit[] unitTable;
        private Dictionary<HMMPosition, IHMM[]> HmmTable;
        private int NumCIUnits;
        private UnitManager unitManager;
       


        protected HMMPool()
        {

        }


        public HMMPool(IAcousticModel model,UnitManager unitManager)
        {
            int maxCIUnits = 0; 
            this.Model = model;
            this.unitManager = unitManager; 
           // TimerPool


            if (model.getLeftContextSize() != 1)
            {
                throw new Exception("LexTreeLinguist: Unsupported left context Size");
            }


            if (model.getRightContextSize() != 1)
            {
                throw new Exception("LexTreeLinguist: Unsupported right context Size"); 

            }

            for (IEnumerator<Unit> I = model.getCotxtIndependentUnitIterator(); I.HasNext(); )
            {
                Unit unit = I.MoveNext();

                if (unit.BaseID > maxCIUnits)
                {
                    maxCIUnits = unit.BaseID;
                }
            }

            maxCIUnits += 1;

            unitTable = new Unit[NumCIUnits * NumCIUnits * NumCIUnits];


            for (IEnumerator<IHMM> i = model.getHMMIterator(); i.HasNext(); )
            {
                IHMM hmm = i.Next();
                Unit unit = hmm.getUnit();
                int id = getID(unit);
                unitTable[id] = unit; 
            }
        }



    }
}
